package com.cqfae.deploycentral.app.web.controller;

/**
 * Created by YANGHENG940 on 2017/7/12.
 */

import com.cqfae.deploycentral.app.utils.GsonUtils;
import com.cqfae.deploycentral.app.services.CommonControllerService;
import com.cqfae.deploycentral.app.services.WindowInfoService;
import com.cqfae.deploycentral.app.utils.NullUtil;
import com.cqfae.deploycentral.app.web.request.WindowInfoRequest;
import com.cqfae.deploycentral.app.web.response.WebResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>发布窗口controller</p>
 *
 * @author yangheng@cmhk.com
 * @since 1.0.0-snapshot
 */
@RestController
@RequestMapping("/deploy-central/windows")
public class WindowInfoController implements CommonControllerService<Object> {

    private static Logger logger = LoggerFactory.getLogger(WindowInfoController.class);

    @Autowired
    private WindowInfoService windowInfoService;

    @RequestMapping(value = "/info")
    public WebResponse pageInfo(WindowInfoRequest request) {
        logger.info("==== pageInfo WindowInfoRequest :==== {}", GsonUtils.getInstance().toJson(request));
        return getWebResponse(windowInfoService.page(request));
    }

    @Override
    public WebResponse getWebResponse(Object obj) {
        WebResponse webResponse = new WebResponse();
        if (NullUtil.isNotEmpty(obj)) {
            webResponse.setData(obj);
        }
        return webResponse;
    }
}
